<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="bean.dal.*,bean.entity.*"%>
<%@page import="bean.common.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<jsp:include page="top.jsp"></jsp:include>
<br/><div align="center">
	 <fieldset style="width: auto; margin: 0px auto;">
		<legend>
		     <font style="font-size:25px" face="宋体">
		          包裹类型管理
		     </font>
		</legend>
	<table border="2" bordercolor="#e2d1c3" width="98%">
		<tr align="center" bordercolor="#e2d1c3">
			<td>编号</td><td>名称</td><td>介绍</td><td>价格</td>
			<td  colspan="1">操作</td>
			
		</tr>
		 <%	
		 TypeManager typeM=new TypeManager();
		    int pagesize = 15;//页面大小
		    int recordCount ;//记录总数
		    int pageCount;//页面总数
		    int pageid;//页面号
		    String  strpageid = request.getParameter("pageid");
		    if(strpageid==null ) pageid=1;
		       else pageid = Integer.parseInt(strpageid); 
		    if(pageid < 1) pageid = 1;
    		recordCount =  typeM.getRecordCountAll();
		    if(recordCount%pagesize==0) pageCount =  recordCount/pagesize ;
		      else pageCount =  recordCount/pagesize +1;
		    if(pageCount<=0) pageCount=1;
   			 if(pageid > pageCount) pageid=pageCount;
    		System.out.println(recordCount);
			 
		    //通过JavaBean的getUsersBypageid(pageid,pagesize)读取某页的记录数据
		  	ArrayList<Goods_type> typelist=null;
		 	Iterator<Goods_type> it = null;
		 	Goods_type type = null;
		    typelist = typeM.getTpye(pageid, pagesize);
		    //newsmanager.closeConn();//不再访问数据库，关闭连接
		    
		    //通过迭代器，列表显示每条记录，并做查看、删除链接
		 	if(typelist!=null){	   it = typelist.iterator();}
		 	
		 	while(it!=null&&it.hasNext()){
		 		type =  it.next();
		 %>
		<tr align="center" bordercolor="#e2d1c3">
			<td><%=type.getTypeid() %></td><td><%=type.getTypename() %></td>
			<td><%=type.getIntroduce() %></td><td><%=type.getPrice() %></td>
			<td><a href="admin/typeitem.jsp?id=<%=type.getId()%>"><input type="button" value="查看"/></a></td>	
		</tr>
		<%} %>
		<tr align="center" bordercolor="#e2d1c3"><td colspan="13"><div>
		 <a href="admin/type.jsp?pageid=1">第一页</a>&nbsp;
		 <a  href="admin/type.jsp?pageid=<%=pageid-1 %>">上一页</a>&nbsp;
		   第<%=pageid %>页/共<%=pageCount %>页&nbsp;
		 <a  href="admin/type.jsp?pageid=<%=pageid+1 %>">下一页</a>&nbsp;
		 <a  href="admin/type.jsp?pageid=<%=pageCount %>">最后一页</a> 	 
		</div></td></tr>
	  </table><br/>
	  <center><a href="admin/addtype.jsp"><input type="button" value="添加包裹类型"/></a>
		 <a href="admin/index.jsp"><input type="button" value="返回"/></a></center>
	  </fieldset>
	  </div>
  </body>
</html>
